Dimension Inference under Polymorphic
نویسنده
چکیده
Numeric types can be given polymorphic dimension parameters , in order to avoid dimension errors and unit errors. The most general dimensions can be inferred automatically. It has been observed that polymorphic recursion is more important for the dimensions than for the proper types. We show that, under polymorphic recursion, type inference amounts to syntactic semi-uniication of proper types, followed by equational semi-uniication of dimensions. Syntactic semi-uniication is unfortunately undecidable, although there are procedures that work well in practice, and proper types given by the programmer can be checked. However, the dimensions form a vector space (provided that their exponents are rational numbers). We give a polynomial-time algorithm that decides if a semi-uniication problem in a vector space can be solved and, if so, returns a most general semi-uniier. 1 Introduction We will combine three good things as far as possible: dimension types, polymorphic recursion, and automatic type inference. Types with dimension parameters can be inferred in two steps: rst you infer the types proper, then you infer the dimensions. Under polymorphic recursion, the rst step is known to be undecidable, but there are partial procedures that seem to work in practice, and types that are given by the programmer can be checked. We will simply assume that for some program, the rst step has been solved (perhaps not with the most general typing), and we study only the remaining step of dimension inference. It will turn out, somewhat surprisingly, that the most general dimensions can be inferred in polynomial time. The rest of section 1 introduces and motivates the three good things. Section 2 reviews some algebraic concepts that are needed: syntactic and equational (semi-)uniica-tion. Section 3 gives an algorithm for semi-uniication in the equational theory for vector spaces. Section 4 motivates that the algorithm can be used to infer dimensions under polymorphic recursion; the reasoning mirrors Henglein's 6]. Section 5 discusses the relative merits of integers and rational numbers as dimension exponents; the integers make the dimensions form a freely generated Abelian group, whereas the rational numbers make them form a vector space. Section 6 discusses how to react to the undecidability of syntactic semi-uniication.
منابع مشابه
Higher-dimensional syntax
The aim of this paper is to present the notion of higher-dimensional syntax, which is a hierarchy of languages. Each term of a n-dimensional language will be typed by terms of the underlying n ? 1-dimensional language. This is an application of the emerging higher-dimensional category notions. On the lower dimensions live notions of syntax which are already known. So dimension zero corresponds ...
متن کاملPolymorphic type inference for the relational algebra
We give a polymorphic account of the relational algebra. We introduce a formalism of \type formulas" speci cally tuned for relational algebra expressions, and present an algorithm that computes the \principal" type for a given expression. The principal type of an expression is a formula that speci es, in a clear and concise manner, all assignments of types (sets of attributes) to relation names...
متن کاملProgramming Examples Needing Polymorphic Recursion
Inferring types for polymorphic recursive function de nitions (abbreviated to polymorphic recursion) is a recurring topic on the mailing lists of popular typed programming languages. This is despite the fact that type inference for polymorphic recursion using 8-types has been proved undecidable. This report presents several programming examples involving polymorphic recursion and determines the...
متن کاملType Checking and Inference for Polymorphic and Existential Types
This paper proves undecidability of type checking and type inference problems in some variants of typed lambda calculi with polymorphic and existential types. First, type inference in the domain-free polymorphic lambda calculus is proved to be undecidable, and then it is proved that type inference is undecidable in the negation, conjunction, and existence fragment of the domain-free typed lambd...
متن کاملMatching Using Sufficient Dimension Reduction for Causal Inference
To estimate casual treatment effects, we propose a new matching approach based on the reduced covariates obtained from sufficient dimension reduction. Compared to the original covariates and the propensity score, which are commonly used for matching in the literature, the reduced covariates are estimable nonparametrically under a mild assumption on the original covariates, and are sufficient an...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1995